package top.jle.wx.proxy.feign.material;

import com.alibaba.fastjson2.JSONObject;
import top.jle.wx.proxy.config.FeignMultipartSupportConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(url = "https://api.weixin.qq.com",name="material",configuration = FeignMultipartSupportConfig.class)
public interface MaterialAPIFeign {

    /**
     * 新增临时素材
     * @param accessToken
     * @param type
     * @param file
     * @return
     */
    @PostMapping(value="/cgi-bin/media/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    JSONObject addTemporary(@RequestParam("type") String type, @RequestPart("media")MultipartFile file);



    /**
     * 新增永久图文素材
     * @param accessToken
     * @param news
     * @return
     */
    @PostMapping("/cgi-bin/material/add_news")
    JSONObject addNews(@RequestBody JSONObject news);


    /**
     * 更新图文素材
     * @param accessToken
     * @param news
     * @return
     */
    @PostMapping("/cgi-bin/material/update_news")
    JSONObject updateNews(@RequestBody JSONObject news);

    /**
     * 删除永久素材
     * @param accessToken
     * @param materialId
     * @return
     */
    @PostMapping("/cgi-bin/material/del_material")
    JSONObject deleteMaterial(@RequestBody JSONObject materialId);

    /**
     * 获取素材总数
     * @param accessToken
     * @return
     */
    @GetMapping("/cgi-bin/material/get_materialcount")
    JSONObject getMaterialCount();


    /**
     * 批量获取素材
     * @param accessToken
     * @param requst
     * @return
     */
    @PostMapping("/cgi-bin/material/batchget_material")
    JSONObject batchGetMaterial(@RequestBody JSONObject requst);

    /**
     * 上传图文消息中的图片
     * @param file
     * @return
     */
    @PostMapping(value = "/cgi-bin/media/uploadimg",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    JSONObject uploadImgForArticle(@RequestPart("media")MultipartFile file);


    /**
     * 上传群发消息使用的图文素材
     * @param news
     * @return
     */
    @PostMapping("/cgi-bin/media/uploadnews")
    JSONObject uploadArticlesForSendAll(@RequestBody JSONObject news);

}
